﻿@model System.Data.DataTable
@{   
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript" src="@Url.Content("~/Scripts/Admin/jquery.dataTables.min.js")"></script>

<div class="grid_16 widget first">
    <div class="widget_title clearfix">
        <h2>
            【按 @ViewBag.Title 统计】</h2>
            <ul>
            <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="@Url.Content("~/StatisticsAdmin/Default")" >
                <span>转到统计首页</span></a> </li>
        </ul>
    </div>
    <div class="widget_body">
        <div class="fg-toolbar ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix" id="SeachDiv">
            <div>
                从
                <input type="text" id="txtStartDay" class="datepicker" value="@ViewBag.StartDay" />
               
                至
                <input type="text" id="txtEndDay"  class="datepicker" value="@ViewBag.EndDay" />
                <a class="btn medium" href="javascript:void(0)" id="btnQuery"><span>【查 询】</span></a>
            </div>
        </div>
        <table class="dataTable">
            <thead>
                <tr>
                    <th>@ViewBag.Title</th>
                    <th class="align-left">访问次数</th>
                    <th class="align-left">新访问次数百分比</th>
                    <th class="align-left">每次访问页数</th>
                    <th class="align-left">平均网站停留时间</th>
                    <th class="align-left">跳出率</th>
                </tr>
            </thead>
            <tbody>
               @for (var i = 0; i < Model.Rows.Count;i++ )
               { 
                <tr>
                <td>@Model.Rows[i][0].ToString()</td>
                <td>@Model.Rows[i][1].ToString()</td>
                <td>@Convert.ToDouble(Model.Rows[i][2].ToString()).ToString("f2")%</td>
                <td>@Convert.ToDouble(Convert.ToDouble(Model.Rows[i][3].ToString()) / Convert.ToDouble(Model.Rows[i][1].ToString())).ToString("f2")</td>
                <td>@Convert.ToDouble(Convert.ToDouble(Model.Rows[i][4].ToString())/60).ToString("f2") 分</td>
                <td>@Convert.ToDouble(Model.Rows[i][5].ToString()).ToString("f2") %</td>
                </tr>
               }
            </tbody>
        </table>
    </div>
</div>
<div class="clear">
    <script type="text/javascript">
       $(document).ready(function () {
           
           $.datepicker.setDefaults({              
               dateFormat:'yy-mm-dd',
               firstDay:1,
               nextText:"下月",
               prevText:"上月",
               dayNamesMin:['日', '一', '二', '三', '四', '五', '六'],
               monthNames:['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
            });

            $("#txtStartDay").attr("readonly","readonly").datepicker({               
                maxDate:$("#txtEndDay").val(),
                onSelect:function(dateText, inst){
                    $('#txtEndDay').datepicker('option', 'minDate',dateText);
                }
            }) 
            $("#txtEndDay").attr("readonly","readonly").datepicker({
                maxDate:"@DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")",
                onSelect: function(dateText, inst){
                    $('#txtStartDay').datepicker('option', 'maxDate',dateText);
                }
            })
                                       

            //Datatable
            $('.dataTable').dataTable({
                "bFilter":true,
                "bLengthChange":true,
                "oLanguage":{ "sUrl": "@Url.Content("/Scripts/Admin/jquery.dataTable.cn.txt")" },
                "sPaginationType":"full_numbers",
                "bJQueryUI":true,
                 "iDisplayLength":25,
                 "aaSorting": [[ 1, "desc" ],[2, "desc"],[3, "desc"]]
            });  
//            $($("#SeachDiv").html()).appendTo($(".dataTables_wrapper div:eq(0)"));
//            $("#SeachDiv").remove();

            $("#btnQuery").click(function(){
                window.location.href="@Url.Content("~/StatisticsAdmin/"+ViewBag.Action+"?startday=")" +encodeURIComponent($("#txtStartDay").val())+"&endday="+encodeURIComponent($("#txtEndDay").val());
            }) 

            $(".dataTable th").hover(function (){
                $(this).css({"cursor":"pointer"});
              },
              function () {
                $(this).css({"cursor":"auto"});
              })
        });  
 
    </script>
</div>


